package com.hsxc.cdz.monitor.bean.server.v1_21;

import com.hsxc.cdz.base.util.BytesUtil;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;

public class ReserveSerMsg extends ServerMessage {

	public static final int length = 11;
	private int chargePort;
	private String cardNum;

	public int getChargePort() {
		return chargePort;
	}

	public void setChargePort(int chargePort) {
		this.chargePort = chargePort;
	}

	public String getCardNum() {
		return cardNum;
	}

	public void setCardNum(String cardNum) {
		this.cardNum = cardNum;
	}

	@Override
	public byte[] getBytesFromMessage() {
		ByteBuf bytes = Unpooled.buffer(length);
		byte[] result;
		byte[] temp;
		// 写出端口号
		temp = BytesUtil.intToBytesSeq(this.getChargePort(), 1);
		bytes.writeBytes(temp);
		// 写出用户卡号
		temp = BytesUtil.strToBcdBytes(this.getCardNum(), 10);
		bytes.writeBytes(temp);
		result = new byte[bytes.readableBytes()];
		bytes.readBytes(result);
		ReferenceCountUtil.release(bytes);
		return result;
	}

}
